home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Garden / Slu4ka v Gradinata */ /* Original Oric BASIC Game by Antoan Hlebarov */ /* Amiga C port by Ventzislav Tzvetkov */ /* All sources are free to use. */ /* Used the freeware C compiler VBCC by Volker Barthelmann */ /* The game is freeware. Enjoy!! */ #include <intuition/intuition.h> #include <libraries/dos.h> #include <hardware/custom.h> #include <hardware/cia.h> #define FIRE 1 #define RIGHT 2 #define LEFT 4 #define DOWN 8 #define UP 16 struct FileHandle *file_handle; long bytes_written; long bytes_read; /* This will automatically be linked to the Custom structure: */ extern struct Custom custom; /* This will automatically be linked to the CIA A (8520) chip: */ extern struct CIA ciaa; UBYTE Joystick(); struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Screen *my_screen; struct Window *my_window; int n,x,y,a,b,mx,my,xd,yd; UBYTE Title1[]={254,254,198,184,202,218,182,160,254,254,206,254,254,174,196,160,168,178,188,160,200,160,254}, Title2[]={255,255,199,185,203,219,183,161,255,255,207,255,255,175,197,161,169,179,189,161,201,161,255}; struct IntuiMessage *my_message; /******************************************/ /* FontData prepared by PrintFont */ /* ------------------------------ */ /* Anders Bjerin Amiga C Club */ /* */ /* Font name: hap.font */ /* Struct name: Hap */ /* Height: 8 */ /* Characters: 32 - 255 */ /******************************************/ /* The font data: */ static UWORD HapData[616]= { /* Row 0: */ 0x0045,0x0A10,0x039E,0x036F,0xD600,0x0000,0x3843,0x9F09, 0xF1DF,0x38E0,0x0008,0x020E,0x38E7,0xD219,0xF11F,0x4515, 0x511D,0x144E,0x7CF7,0x8E7D,0x155E,0x4303,0x9581,0x5452, 0x1800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0010,0x0003,0xDB61,0x8053,0xF061,0xF800, 0x00FD,0x2AB7,0x0007,0xC003,0xEE10,0x4191,0x8E39,0x17D1, 0x7924,0x8629,0x0115,0x7D04,0x4A45,0x9551,0x5072,0x5144, 0xE45F,0x3D03,0x907C,0x4441,0x5554,0x3038,0x1555,0x5414, 0x9500,0xA000,0xFD5F,0x2000,0x093F,0x000D,0xFFFF,0xF700, 0x000F,0x9803,0x0FF0,0xC3F0,0x0000, /* Row 1: */ 0x0045,0x0A3D,0x157F,0x03E8,0x5F00,0x0001,0x44C4,0x4119, 0x0201,0x4511,0x0410,0x0111,0x4514,0x1229,0x0390,0x4514, 0x5225,0xB451,0x4514,0x5111,0x1551,0x4104,0x5541,0x5455, 0x1800,0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0010,0x000F,0xDB60,0xC093,0xF0C1,0xF803, 0x60FC,0x9548,0x0C68,0x1F3C,0x2A1F,0x7DF1,0x8E39,0x17D1, 0x7924,0x8629,0x0115,0x7D04,0x4A45,0x9551,0x5072,0x5144, 0xE45F,0x3D03,0x907C,0x4441,0x5554,0x3038,0x1555,0x5414, 0x95C5,0xF545,0x7DFF,0x1000,0x4DBF,0x004F,0xFFFF,0xFF80, 0x000F,0x0C06,0x8FC0,0x03F0,0x0100, /* Row 2: */ 0x0040,0x1F42,0xA39E,0x0148,0x4F00,0x0003,0x4C40,0x4229, 0xE402,0x4511,0x0421,0xF081,0x5D14,0x1229,0x0550,0x2934, 0xD425,0x5451,0x4514,0x5011,0x1551,0x4100,0x5521,0x5455, 0x0CE7,0xD218,0xE11F,0x8924,0x921D,0xB48E,0x7CF7,0x8E7D, 0x155E,0x4183,0x9511,0x54BC,0xF880,0x409F,0xF183,0xF807, 0xF001,0x2577,0x31FB,0xD940,0x2B90,0x4190,0x0045,0x1411, 0x4524,0x8A7D,0x038E,0x4104,0x5145,0x1452,0x4892,0x5B45, 0x1451,0x4504,0x5110,0x4441,0x5554,0x1045,0x1555,0x5415, 0x55EF,0xFFCF,0xFFFF,0x8800,0x6FFF,0x006F,0xFFFF,0xE000, 0x001E,0x020C,0x0FC0,0x03F0,0x2900, /* Row 3: */ 0x0040,0x0A39,0x410C,0x03E8,0x5F01,0xF006,0x5441,0x8648, 0x1784,0x38F0,0x0040,0x0042,0x55F7,0x9229,0xE550,0x1155, 0x5825,0x57D1,0x44F7,0x9010,0xF7DE,0x79E1,0x9511,0x53DD, 0x0014,0x1229,0x1390,0x5124,0x9425,0xF491,0x4594,0x5111, 0x1551,0x4080,0x5511,0x5570,0xF880,0x009F,0x1103,0x980F, 0xF800,0x9A88,0xC3FB,0xD958,0x389F,0x4193,0xDF45,0x1411, 0x4524,0x8A7D,0x038E,0x4104,0x5145,0x1452,0x4892,0x5B45, 0x1451,0x4504,0x5110,0x4441,0x5554,0x1045,0x1555,0x5415, 0x553F,0xFFDF,0x7FFF,0xDC01,0x7FFF,0x027F,0xF87F,0xCF80, 0x0032,0x0218,0x0CC0,0x83F0,0x3300, /* Row 4: */ 0x0040,0x1F04,0xA7FF,0x0368,0x4F00,0x000C,0x6442,0x017C, 0x1448,0x4410,0x0021,0xF084,0x5D14,0x5229,0x0550,0x2996, 0x5425,0x1451,0x4514,0x1010,0x1551,0x4510,0x5509,0x5055, 0x00F7,0x9229,0xF550,0x2165,0x9825,0x5791,0x44F7,0x9010, 0xF7DE,0x78E1,0x9511,0x5743,0x52B0,0x005E,0x1007,0x180F, 0xF801,0x2AB7,0xC3FB,0xD958,0x0ED0,0x4195,0xAE45,0x141E, 0x4527,0xCA45,0xF544,0x4102,0x914D,0x14D4,0x4494,0x5545, 0x1391,0x4504,0x0E10,0x444E,0x5554,0x1004,0xE55F,0x7C15, 0x527F,0xFFFF,0xFFF0,0x0803,0x7FFF,0x037F,0xF003,0x8F80, 0x0072,0x0230,0x0CC0,0xC310,0x3F00, /* Row 5: */ 0x0000,0x0A79,0x539E,0x5488,0x5F18,0x0198,0x4444,0x1109, 0x1448,0x4421,0x0410,0x0100,0x4114,0x527D,0x0390,0x4514, 0x5225,0x1451,0x4514,0x1110,0x1551,0x4514,0x5505,0x5055, 0x0194,0x527D,0x0390,0x51A6,0x9425,0x1491,0x4454,0x1110, 0x1551,0x4490,0x5511,0x554F,0x52B0,0x7053,0xF007,0x184F, 0xF800,0x9548,0x31F8,0x1940,0x021F,0x7DF1,0x8E45,0x141E, 0x4527,0xCA45,0xF544,0x4102,0x914D,0x14D4,0x4494,0x5545, 0x1391,0x4504,0x0E10,0x444E,0x5554,0x1004,0xE55F,0x7C15, 0x52E7,0xFFDF,0x7FF0,0x0413,0xFFFF,0x03FC,0x7003,0x8F80, 0x00FE,0x0260,0x0CC0,0xE300,0x1E00, /* Row 6: */ 0x0040,0x0A12,0x229E,0xAAB8,0x5618,0x01B0,0x38E7,0xCE08, 0xE388,0x38C1,0x0408,0x0204,0x3D17,0x9F45,0xF110,0x4514, 0x5145,0x144E,0x4514,0x0E10,0xE55E,0x79E3,0x9F01,0xF052, 0x00F7,0x9F44,0xF110,0x8924,0x9245,0x148E,0x4494,0x0E10, 0xE55E,0x78E3,0x9F11,0xF4BC,0xF9E0,0x1873,0xF007,0x38C7, 0xF0FD,0x2577,0x0C67,0xDF3C,0x0390,0x4192,0x517C,0x0780, 0x7920,0x4A00,0x0540,0x4001,0x0054,0x0558,0x0090,0x157D, 0x1011,0x3D04,0x0010,0x03C0,0x7C07,0x9E18,0x0540,0x0407, 0x40C7,0xFFFF,0xFFF0,0x031B,0xFFFF,0x07F0,0x7803,0xC700, 0x05CF,0x0CC0,0x1DC0,0xE300,0x4C00, /* Row 7: */ 0x0000,0x0000,0x02B3,0x01EF,0xC030,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0800,0x0000,0x0000,0x0100,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1000, 0x0000,0x0100,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x1000,0xF9E0,0x0CD3,0xF00E,0x7943, 0xE0FC,0x9A88,0x0000,0x0000,0x00DF,0x4194,0x117C,0x0780, 0x7920,0x4A00,0x0540,0x4001,0x0054,0x0558,0x0090,0x157D, 0x1011,0x3C04,0x0010,0x03C0,0x7C07,0x9E18,0x0540,0x0407, 0x40F9,0xF7DF,0x7FF0,0x039F,0xFFFF,0x1F80,0x7E03,0xEFF0, 0x038F,0x9880,0x3FC0,0xC300,0xC000 }; /* The location and width of each character: */ static ULONG HapLoc[224]= { 0x00000006,0x00060006,0x000C0006,0x00120006, 0x00180006,0x001E0006,0x00240006,0x002A0006, 0x00300006,0x00360006,0x003C0006,0x00420006, 0x00480006,0x004E0006,0x00540006,0x005A0006, 0x00600006,0x00660006,0x006C0006,0x00720006, 0x00780006,0x007E0006,0x00840006,0x008A0006, 0x00900006,0x00960006,0x009C0006,0x00A20006, 0x00A80006,0x00AE0006,0x00B40006,0x00BA0006, 0x00C00006,0x00C60006,0x00CC0006,0x00D20006, 0x00D80006,0x00DE0006,0x00E40006,0x00EA0006, 0x00F00006,0x00F60006,0x00FC0006,0x01020006, 0x01080006,0x010E0006,0x01140006,0x011A0006, 0x01200006,0x01260006,0x012C0006,0x01320006, 0x01380006,0x013E0006,0x01440006,0x014A0006, 0x01500006,0x01560006,0x015C0006,0x01620006, 0x01680006,0x016E0006,0x01740006,0x017A0006, 0x01800006,0x01860006,0x018C0006,0x01920006, 0x01980006,0x019E0006,0x01A40006,0x01AA0006, 0x01B00006,0x01B60006,0x01BC0006,0x01C20006, 0x01C80006,0x01CE0006,0x01D40006,0x01DA0006, 0x01E00006,0x01E60006,0x01EC0006,0x01F20006, 0x01F80006,0x01FE0006,0x02040006,0x020A0006, 0x02100006,0x02160006,0x021C0006,0x02220006, 0x02280006,0x022E0006,0x02340006,0x023A0006, 0x02400006,0x02460006,0x024C0006,0x02520006, 0x02580006,0x025E0006,0x02640006,0x026A0006, 0x02700006,0x02760006,0x027C0006,0x02820006, 0x02880006,0x02880006,0x028E0006,0x02940006, 0x029A0006,0x02A00006,0x02A60006,0x02AC0006, 0x02B20006,0x02B20006,0x02B20006,0x02B20006, 0x02B80006,0x02BE0006,0x02C40006,0x02CA0006, 0x02D00006,0x02D60006,0x02DC0006,0x02E20006, 0x02E80006,0x02EE0006,0x02F40006,0x02FA0006, 0x03000006,0x02FA0006,0x03060006,0x030C0006, 0x03120006,0x03180006,0x02F40006,0x031E0006, 0x03240006,0x032A0006,0x03300006,0x03360006, 0x033C0006,0x03420006,0x03480006,0x034E0006, 0x03540006,0x034E0006,0x035A0006,0x03600006, 0x03660006,0x036C0006,0x03720006,0x02EE0006, 0x03780006,0x02EE0006,0x037E0006,0x03840006, 0x038A0006,0x02EE0006,0x03900006,0x02EE0006, 0x03000006,0x03960006,0x039C0006,0x03A20006, 0x03A80006,0x03AE0006,0x03B40006,0x03BA0006, 0x03C00006,0x03C60006,0x03000006,0x02FA0006, 0x03CC0006,0x02FA0006,0x03D20006,0x02FA0006, 0x03D80006,0x03DE0006,0x03E40006,0x03EA0006, 0x03E40006,0x03F00006,0x03B40006,0x03F60006, 0x03FC0006,0x04020006,0x04080006,0x040E0006, 0x04140006,0x041A0006,0x04200006,0x04260006, 0x042C0006,0x04320006,0x04380006,0x043E0006, 0x04440006,0x044A0006,0x04500006,0x04560006, 0x045C0006,0x04620006,0x04680006,0x046E0006, 0x04740006,0x047A0006,0x04800006,0x04860006, 0x048C0006,0x04920006,0x04980006,0x049E0006, 0x04A40006,0x04AA0006,0x04B00006,0x04B60006, 0x04BC0006,0x04C20006,0x00000006,0x00000006 }; /* The text font structure: */ struct TextFont HapFont= { { /* Message */ { /* Node */ NULL, /* ln_Succ */ NULL, /* ln_Pred */ NT_FONT, /* ln_Type */ 0, /* ln_Pri */ "hap.font" /* ln_Name */ }, NULL, /* mn_ReplyPort */ 2132 /* mn_Length */ }, 8, /* tf_YSize */ 0, /* tf_Style */ 66, /* tf_Flags */ 6, /* tf_XSize */ 6, /* tf_Baseline */ 1, /* tf_BoldSmear */ 0, /* tf_Accessors */ 32, /* tf_LoChar */ 255, /* tf_HiChar */ (APTR) &HapData, /* tf_CharData */ 154, /* tf_Modulo */ (APTR) &HapLoc, /* tf_CharLoc */ NULL, /* tf_CharSpace */ NULL, /* tf_CharKern */ }; /******************************************/ /* The body text for the about info: */ /* Gadgets */ struct Gadget my_first_gadget= { NULL, /* NextGadget, no more gadgets in the list. */ 180, /* LeftEdge, 180 pixels out. */ 64, /* TopEdge, 20 lines down. */ 12, /* Width, 12 pixels wide. */ 16, /* Height, 16 pixels lines heigh. */ GADGHNONE, /* Flags, no highlighting. */ GADGIMMEDIATE, /* When the user selects the gadget*/ /* has released it. */ BOOLGADGET, /* GadgetType, a Boolean gadget. */ NULL, NULL, /* SelectRender */ NULL, /* GadgetText, a pointer to our IntuiText structure. */ NULL, /* MutualExclude, no mutual exclude. */ NULL, /* SpecialInfo, NULL since this is a Boolean gadget. */ /* (It is not a Proportional/String or Integer gdget) */ 0, /* GadgetID, no id. */ NULL /* UserData, no user data connected to the gadget. */ }; struct Gadget my_second_gadget= { &my_first_gadget, /* NextGadget, after this comes my_first_gadget. */ 180, /* LeftEdge, 180 pixels out. */ 96, /* TopEdge, 20 lines down. */ 12, /* Width, 12 pixels wide. */ 16, /* Height, 16 pixels lines heigh. */ GADGHNONE, /* Flags, no highlighting. */ GADGIMMEDIATE, /* When the user selects the gadget*/ /* has released it. */ BOOLGADGET, /* GadgetType, a Boolean gadget. */ NULL, NULL, /* SelectRender */ NULL, /* GadgetText, a pointer to our IntuiText structure. */ NULL, /* MutualExclude, no mutual exclude. */ NULL, /* SpecialInfo, NULL since this is a Boolean gadget. */ /* (It is not a Proportional/String or Integer gdget) */ 0, /* GadgetID, no id. */ NULL /* UserData, no user data connected to the gadget. */ }; struct Gadget my_third_gadget= { &my_second_gadget,/* NextGadget, after this comes my_first_gadget. */ 180, /* LeftEdge, 180 pixels out. */ 128, /* TopEdge, 20 lines down. */ 12, /* Width, 12 pixels wide. */ 16, /* Height, 16 pixels lines heigh. */ GADGHNONE, /* Flags, no highlighting. */ GADGIMMEDIATE, /* When the user selects the gadget*/ /* has released it. */ BOOLGADGET, /* GadgetType, a Boolean gadget. */ NULL, NULL, /* SelectRender */ NULL, /* GadgetText, a pointer to our IntuiText structure. */ NULL, /* MutualExclude, no mutual exclude. */ NULL, /* SpecialInfo, NULL since this is a Boolean gadget. */ /* (It is not a Proportional/String or Integer gdget) */ 0, /* GadgetID, no id. */ NULL /* UserData, no user data connected to the gadget. */ }; /* Text for the About Menu Item */ struct IntuiText my_body_text= { 0, /* FrontPen, colour 0 (blue). */ 0, /* BackPen, not used since JAM1. */ JAM1, /* DrawMode, do not change the background. */ 15, /* LedtEdge, 15 pixels out. */ 5, /* TopEdge, 5 lines down. */ NULL, /* ITextFont, default font. */ "Copyright © 2002", /* IText, the text . */ NULL, /* NextText, no more IntuiText structures link. */ }; /* The OK text: */ struct IntuiText my_ok_text= { 0, /* FrontPen, colour 0 (blue). */ 0, /* BackPen, not used since JAM1. */ JAM1, /* DrawMode, do not change the background. */ 6, /* LedtEdge, 6 pixels out. */ 3, /* TopEdge, 3 lines down. */ NULL, /* ITextFont, default font. */ "OK", /* IText, the text that will be printed. */ NULL, /* NextText, no more IntuiText structures link. */ }; /* Game's Screen */ struct NewScreen my_new_screen= { 0, /* LeftEdge Should always be 0. */ 0, /* TopEdge Top of the display.*/ 320, /* Width We are using a low-resolution screen. */ 256, /* Height Non-Interlaced PAL (European) display. */ 3, /* Depth 8 colours. */ 0, /* DetailPen Text should be drawn with colour reg. 0 */ 1, /* BlockPen Blocks should be drawn with colour reg. 1 */ NULL, /* ViewModes No special modes. (Low-res, Non-Interlaced) */ CUSTOMSCREEN, /* Type Your own customized screen. */ NULL, /* Font Default font. */ "Garden",/* Title The screen' title. */ NULL, /* Gadget Must for the moment be NULL. */ NULL /* BitMap No special CustomBitMap. */ }; struct NewWindow my_new_window= { 0, /* LeftEdge x position of the window. */ 0, /* TopEdge y positio of the window. */ 320, /* Width 150 pixels wide. */ 256, /* Height 100 lines high. */ 0, /* DetailPen Text should be drawn with colour reg. 0 */ 1, /* BlockPen Blocks should be drawn with colour reg. 1 */ MENUPICK, /* IDCMPFlags. */ SMART_REFRESH|BORDERLESS|ACTIVATE, /* Flags Intuition should refresh the window. */ &my_third_gadget,/* FirstGadget. */ NULL, /* CheckMark Use Intuition's default CheckMark (v). */ NULL, /* Title Title of the window. */ NULL, /* Screen Connected to the Workbench Screen. */ NULL, /* BitMap No Custom BitMap. */ 0,0,0,0, CUSTOMSCREEN /* Type Connected to custom Screen. */ }; struct IntuiText my_third_text= { 2, /* FrontPen, black. */ 0, /* BackPen, not used since JAM1. */ JAM1, /* DrawMode, do not change the background. */ 0, /* LeftEdge, CHECKWIDTH amount of pixels out. */ /* This will leave enough space for the check mark. */ 1, /* TopEdge, 1 line down. */ NULL, /* TextAttr, default font. */ "Quit", /* IText, the string. */ NULL /* NextItem, no link to other IntuiText structures. */ }; struct MenuItem my_third_item= { NULL, /* &my_third_item, */ /* NextItem, linked to the third item. */ 0, /* LeftEdge, 0 pixels out. */ 20, /* TopEdge, 10 lines down. */ 150, /* Width, 150 pixels wide. */ 10, /* Height, 10 lines high. */ ITEMTEXT| /* Flags, render this item with text. */ ITEMENABLED| /* this item will be enabled. */ COMMSEQ| /* accessible from the keyboard. */ HIGHCOMP, /* complement the colours when highlihted. */ 0x00000000, /* MutualExclude, mutualexclude the first item only. */ (APTR) &my_third_text, /* ItemFill, pointer to the text. */ NULL, /* SelectFill, nothing since we complement the col. */ 'Q', /* Command, no command-key sequence. */ NULL, /* SubItem, no subitem list. */ MENUNULL, /* NextSelect, no items selected. */ }; struct IntuiText my_second_text= { 2, /* FrontPen, black. */ 0, /* BackPen, not used since JAM1. */ JAM1, /* DrawMode, do not change the background. */ 0, /* LeftEdge, CHECKWIDTH amount of pixels out. */ /* This will leave enough space for the check mark. */ 1, /* TopEdge, 1 line down. */ NULL, /* TextAttr, default font. */ "About", /* IText, the string. */ NULL /* NextItem, no link to other IntuiText structures. */ }; struct MenuItem my_second_item= { &my_third_item, /* NextItem, linked to the third item. */ 0, /* LeftEdge, 0 pixels out. */ 10, /* TopEdge, 10 lines down. */ 150, /* Width, 150 pixels wide. */ 10, /* Height, 10 lines high. */ ITEMTEXT| /* Flags, render this item with text. */ ITEMENABLED| /* this item will be enabled. */ COMMSEQ| /* accessible from the keyboard. */ HIGHCOMP, /* complement the colours when highlihted. */ 0x00000000, /* MutualExclude, mutualexclude the first item only. */ (APTR) &my_second_text, /* ItemFill, pointer to the text. */ NULL, /* SelectFill, nothing since we complement the col. */ 'A', /* Command, no command-key sequence. */ NULL, /* SubItem, no subitem list. */ MENUNULL, /* NextSelect, no items selected. */ }; struct IntuiText my_first_text= { 2, /* FrontPen, black. */ 0, /* BackPen, not used since JAM1. */ JAM1, /* DrawMode, do not change the background. */ 0, /* LeftEdge, CHECKWIDTH amount of pixels out. */ /* This will leave enough space for the check mark. */ 1, /* TopEdge, 1 line down. */ NULL, /* TextAttr, default font. */ "New Game", /* IText, the string. */ NULL /* NextItem, no link to other IntuiText structures. */ }; struct MenuItem my_first_item= { &my_second_item, /* NextItem, linked to the second item. */ 0, /* LeftEdge, 0 pixels out. */ 0, /* TopEdge, 0 lines down. */ 150, /* Width, 150 pixels wide. */ 10, /* Height, 10 lines high. */ ITEMTEXT| /* Flags, render this item with text. */ ITEMENABLED| /* this item will be enabled. */ COMMSEQ| /* accessible from the keyboard. */ HIGHCOMP, /* complement the colours when highlihted. */ 0x00000000, /* MutualExclude, , no mutualexclude. */ (APTR) &my_first_text, /* ItemFill, pointer to the text. */ NULL, /* SelectFill, nothing since we complement the col. */ 'N', /* Command, no command-key sequence. */ NULL, /* SubItem, no subitem list. */ MENUNULL, /* NextSelect, no items selected. */ }; struct Menu my_menu= { NULL, /* NextMenu, no more menu structures. */ 0, /* LeftEdge, left corner. */ 0, /* TopEdge, for the moment ignored by Intuition. */ 50, /* Width, 50 pixels wide. */ 0, /* Height, for the moment ignored by Intuition. */ MENUENABLED, /* Flags, this menu will be enabled. */ "Garden",/* MenuName, the string. */ &my_first_item /* FirstItem, pointer to the first item in the list. */ }; main() { BOOL close=0; int l=10,bs,hiscore[2]={0,0},i,Score=0; char score[5]={48,48,48,48,48},bar=42; /* Opens the highscore file */ file_handle = (struct FileHandle *) Open( "GardenHighscores.sav", MODE_READWRITE ); Seek( file_handle, 0, OFFSET_BEGINNING ); bytes_read = Read( file_handle, hiscore, sizeof( hiscore ) ); /* Open the Intuition library: */ IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 0 ); if( !IntuitionBase ) exit(); /* Open the Graphics library: */ GfxBase = (struct GfxBase *) OpenLibrary( "graphics.library", 0 ); if( !GfxBase ) { CloseLibrary( IntuitionBase ); exit(); } /* We will now try to open the screen: */ my_screen = (struct Screen *) OpenScreen( &my_new_screen ); if( !my_screen ) { CloseLibrary( GfxBase ); CloseLibrary( IntuitionBase ); exit(); } SetRGB4( &my_screen->ViewPort, 0, 0,0,0 ); SetRGB4( &my_screen->ViewPort, 1, 0,0,15 ); SetRGB4( &my_screen->ViewPort, 2, 6,6,15 ); SetRGB4( &my_screen->ViewPort, 3, 15,0,0 ); SetRGB4( &my_screen->ViewPort, 4, 7,3,0 ); SetRGB4( &my_screen->ViewPort, 5, 0,15,9 ); SetRGB4( &my_screen->ViewPort, 6, 0,11,15 ); SetRGB4( &my_screen->ViewPort, 7, 15,15,0); my_new_window.Screen = my_screen; my_window = (struct Window *) OpenWindow( &my_new_window ); if ( !my_window ) { /* Could NOT open the Window! */ /* Close the Intuition Library since we have opened it: */ CloseScreen( my_screen ); CloseLibrary( GfxBase ); CloseLibrary( IntuitionBase ); exit(); } SetFont( my_window->RPort, &HapFont ); Title(); SetMenuStrip( my_window, &my_menu ); /* Stay in the while loop until the end */ while( close == FALSE ) { x=36;y=5;mx=l;my=5;xd=1;yd=0;n=0; SetAPen(my_window->RPort,0); RectFill(my_window->RPort,0,0,319,255); SetAPen(my_window->RPort,4); Move( my_window->RPort,24,8); Text( my_window->RPort, "Rezultat",8); Move( my_window->RPort,144,8); Text( my_window->RPort, "Rekord",8); bs=Score; score[0]=(bs/10000)+48;bs=bs%10000; score[1]=(bs/1000)+48;bs=bs%1000; score[2]=(bs/100)+48;bs=bs%100; score[3]=(bs/10)+48;bs=bs%10; score[4]=bs+48; Move( my_window->RPort,78,8); Text( my_window->RPort, &score[0],5); bs=hiscore[1]; score[0]=(bs/10000)+48;bs=bs%10000; score[1]=(bs/1000)+48;bs=bs%1000; score[2]=(bs/100)+48;bs=bs%100; score[3]=(bs/10)+48;bs=bs%10; score[4]=bs+48; Move( my_window->RPort,186,8); Text( my_window->RPort, &score[0],5); SetAPen(my_window->RPort,1); for (i=4; i<38; i++) {Move ( my_window->RPort,i*6,32);Text( my_window->RPort, &bar,1);Move ( my_window->RPort,246-i*6,168);Text( my_window->RPort, &bar,1);} for (i=4; i<38; i=i+2) {Move ( my_window->RPort,24,16+i*4);Text( my_window->RPort, &bar,1);Move ( my_window->RPort,222,184-i*4);Text( my_window->RPort, &bar,1);} SetAPen(my_window->RPort,5); for (i=6; i<21; i++) {Move ( my_window->RPort,30,i*8);Text( my_window->RPort, "((((((((((((((((((((((((((((((((",32); } SetAPen(my_window->RPort,6); for (i=1; i<21; i++){ Move (my_window->RPort,30+(rand()%32)*6,48+(rand()%15)*8); Text( my_window->RPort, &bar,1); } SetAPen(my_window->RPort,2); i=0; while (i<l) { a=rand()%32; b=rand()%15; if ( ReadPixel(my_window->RPort,30+a*6,48+b*8)==5 && a!=32 && b!=1) {Move (my_window->RPort,30+a*6,48+b*8); Text (my_window->RPort, ")",1); i++;} } SetAPen(my_window->RPort,7); Move (my_window->RPort,x*6,y*8); Text (my_window->RPort, "&",1); /* That's You! */ SetAPen(my_window->RPort,3); Move (my_window->RPort,mx*6,my*8); Text (my_window->RPort, "'",1); /* This is Zorak */ while (1) {a=Joystick(); if (a==LEFT || a==RIGHT || a==UP || a==DOWN ) break; my_message = (struct IntuiMessage *) GetMsg(my_window->UserPort); if (close) break; /* After we have successfully collected the message we can read */ /* it, and save any important values which we maybe want to check */ /* later: */ if(my_message->Class == MENUPICK && my_message->Code == 63488) {Score=0;l=10;i=500;break;} /* New Game */ if(my_message->Class == MENUPICK && my_message->Code == 63520) AutoRequest( my_window, &my_body_text, NULL, &my_ok_text, NULL, NULL, 220, 72); /* About */ if(my_message->Class == MENUPICK && my_message->Code == 63552) { close=TRUE; /* Quit */ break;} } /* while-loop: */ while(1) { a=x; b=y; while(1) { if (Joystick() & LEFT && x>5) {x--; ;break; } if (Joystick() & RIGHT && x<36){x++;break;} if (Joystick() & UP && y>5){y--;break;} if (Joystick() & DOWN && y<20) y++; break; } if (ReadPixel (my_window->RPort,x*6+4,y*8-2)==2) {Score=Score+10; n++;} if (ReadPixel (my_window->RPort,x*6+5,y*8-1)==6) {x=a;y=b;} if ((b!=y || a!=x) && ReadPixel (my_window->RPort,x*6+5,y*8-1)==5) Score++; Move (my_window->RPort,a*6,b*8); Text (my_window->RPort, " ",1); SetAPen(my_window->RPort,7); Move (my_window->RPort,x*6,y*8); Text (my_window->RPort, "&",1); /* That's You */ SetAPen(my_window->RPort,4); bs=Score; score[0]=(bs/10000)+48;bs=bs%10000; score[1]=(bs/1000)+48;bs=bs%1000; score[2]=(bs/100)+48;bs=bs%100; score[3]=(bs/10)+48;bs=bs%10; score[4]=bs+48; Move( my_window->RPort,78,8); Text( my_window->RPort, &score[0],5); Delay(1); a=mx;b=my;mx=mx+xd;my=my+yd; while (1) { if (mx==x && my==y) {Text (my_window->RPort, " ",1);break;} if (mx<5 || mx>36 || my>20 || my<5) {mx=a;my=b;Algo();break;} if ((ReadPixel (my_window->RPort,mx*6+5,my*8-1)!=0) || (ReadPixel (my_window->RPort,mx*6+3,my*8-2)!=0)) {mx=a;my=b;Algo();break;} if (xd!=0) {if (my<y) if ((ReadPixel (my_window->RPort,mx*6+5,my*8+7)==0) && (ReadPixel (my_window->RPort,mx*6+3,my*8+6)==0)) {yd=1;xd=0;break;} if (my>y) if ((ReadPixel (my_window->RPort,mx*6+5,my*8-9)==0) && (ReadPixel (my_window->RPort,mx*6+3,my*8-10)==0)) {yd=-1;xd=0; break;} break; } if (mx<x) if ((ReadPixel (my_window->RPort,mx*6+11,my*8-1)==0) && (ReadPixel (my_window->RPort,mx*6+9,my*8-2)==0)) {xd=1;yd=0;break;} if (mx>x) if ((ReadPixel (my_window->RPort,mx*6-1,my*8-1)==0) && (ReadPixel (my_window->RPort,mx*6-3,my*8-2)==0)) {xd=-1;yd=0;break;} break; } Move (my_window->RPort,a*6,b*8); Text (my_window->RPort, " ",1); SetAPen(my_window->RPort,3); Move (my_window->RPort,mx*6,my*8); Text (my_window->RPort, "'",1); /* This is Zorak */ my_message = (struct IntuiMessage *) GetMsg(my_window->UserPort); if (close) break; /* After we have successfully collected the message we can read */ /* it, and save any important values which we maybe want to check */ /* later: */ if(my_message->Class == MENUPICK && my_message->Code == 63488) {Score=0;l=10;break;} /* New Game */ if(my_message->Class == MENUPICK && my_message->Code == 63520) AutoRequest( my_window, &my_body_text, NULL, &my_ok_text, NULL, NULL, 220, 72); /* About */ if(my_message->Class == MENUPICK && my_message->Code == 63552) { close=TRUE; /* Quit */ break;} if (mx==x && my==y) { SetAPen (my_window->RPort,7); Move (my_window->RPort,24,184); Text (my_window->RPort, "Kraj na igrata !",16); if (Score>hiscore[1]) {hiscore[1]=Score; SetAPen (my_window->RPort,3); Move (my_window->RPort,114,184); Text (my_window->RPort, "S now rekord !",14); Seek( file_handle, 0, OFFSET_BEGINNING ); bytes_written=Write( file_handle, hiscore, sizeof( hiscore ) ); } for (i=1; i<500; i++) { my_message = (struct IntuiMessage *) GetMsg(my_window->UserPort); if (close) break; /* After we have successfully collected the message we can read */ /* it, and save any important values which we maybe want to check */ /* later: */ if((my_message->Class == MENUPICK && my_message->Code == 63488) || Joystick() & FIRE) {i=500;Score=0;l=10;break;} /* New Game */ if(my_message->Class == MENUPICK && my_message->Code == 63520) AutoRequest( my_window, &my_body_text, NULL, &my_ok_text, NULL, NULL, 220, 72); /* About */ if(my_message->Class == MENUPICK && my_message->Code == 63552) { close=TRUE; /* Quit */ break;} Delay(1);} } if (i==500) break; if (n==l) {if (l<35) l++;break;} Delay(1); } } /* We should always close the screens we have opened before we leave: */ ClearMenuStrip( my_window ); Close( file_handle ); CloseWindow ( my_window ); CloseScreen( my_screen ); /* Close the Graphics Library since we have opened it: */ CloseLibrary( GfxBase ); /* Close the Intuition Library since we have opened it: */ CloseLibrary( IntuitionBase ); /* THE END */ exit(); } void Title() { UBYTE fl=128, fr=129; int i,j,b=0; SetAPen(my_window->RPort,2); for (i=1; i<30; i=i+2) {for (j=1; j<53; j=j+2) {Move( my_window->RPort,(j-b)*6,i*8); Text( my_window->RPort, &fl, 1 ); Move( my_window->RPort,(j-b)*6,(i+1)*8); Text( my_window->RPort, &fr, 1 );} if (b==0) b=-1; else b=0;} SetAPen(my_window->RPort,3); Move( my_window->RPort,102,120); Text( my_window->RPort, &Title1, 23 ); Move( my_window->RPort,102,128); Text( my_window->RPort, &Title2, 23 ); while (b<250) {b++;Delay(1); if (Joystick()==FIRE) b=255;} } /* Joystick() is a handy, easy and fast but naughty function that hits */ /* the hardware of the Amiga. It returns a bitfield containing the */ /* position of the stick and the present state of the button. */ /* */ /* Synopsis: value = Joystick(); */ /* */ /* value: (UBYTE) If the fire button is pressed, the first bit is */ /* set. If the stick is moved to the right, the second bit */ /* is set, and if the stick is moved to the left, the third */ /* bit is set. The fourth bit is set if the stick is moved */ /* down, and the fifth bit is set if the stick is moved up. */ /* FIRE==1 RIGHT==2 LEFT==4 DOWN==8 UP==16 */ UBYTE Joystick() { UBYTE data = 0; UWORD joy; /* PORT 2 ("JOYSTICK PORT") */ joy = custom.joy1dat; data += !( ciaa.ciapra & 0x0080 ) ? FIRE : 0; data += joy & 0x0002 ? RIGHT : 0; data += joy & 0x0200 ? LEFT : 0; data += (joy >> 1 ^ joy) & 0x0001 ? DOWN : 0; data += (joy >> 1 ^ joy) & 0x0100 ? UP : 0; return( data ); } void Algo () { while (1) { if (xd!=0) {if (my<20) if ((ReadPixel (my_window->RPort,mx*6+5,my*8+7)==0) && (ReadPixel (my_window->RPort,mx*6+3,my*8+6)==0)) {yd=1;xd=0;break;} if (my>5) if ((ReadPixel (my_window->RPort,mx*6+5,my*8-9)==0) && (ReadPixel (my_window->RPort,mx*6+3,my*8-10)==0)) { yd=-1;xd=0; break;} xd=-xd;yd=-yd;break;} if (mx<31) if ((ReadPixel (my_window->RPort,mx*6+11,my*8-1)==0) && (ReadPixel (my_window->RPort,mx*6+9,my*8-2)==0)) {xd=-1;yd=0;break;} xd=-xd;yd=-yd;break; } } /* Here comes the original AmigaBASIC code, which was written in 1995 The font now is included in the executable, and it's not external anymore. If you need cyrillic font for Amiga try: http://wuarchive.wustl.edu/~aminet/aminet/text/bfont/BTopaz.lha SCREEN 1,337,256,4,1:WINDOW 1,"Venci",,1,1:PALETTE 0,0,0,0:PALETTE 1,0,0,0 PALETTE 4,0,9/15,1 PALETTE 9,1,0,0:PALETTE 10,1,1,0 PALETTE 11,10/15,3/15,0 PALETTE 15,0,0,1 DECLARE FUNCTION AskSoftStyle& LIBRARY DECLARE FUNCTION OpenDiskFont& LIBRARY DECLARE FUNCTION Execute& LIBRARY LIBRARY "graphics.library" LIBRARY "diskfont.library" Font "hap.font",8,0,0 SUB Font(fontName$, height%, style%, prefs%) STATIC SHARED pFont& IF pFont&<>0 THEN CALL CloseFont(pFont&) fontName0$=fontName$+CHR$(0) textAttr&(0)=SADD(fontName0$) textAttr&(1)=height%*65536& + style%*256 + prefs% pFont&=OpenDiskFont&(VARPTR(textAttr&(0))) IF pFont& <> 0 THEN SetFont WINDOW(8),pFont& END SUB E$="*":GOSUB Title 20 s=0:l=10 30 x=36:y=5:mx=l:my=5:xd=1:yd=0:n=0:CLS COLOR 8:LOCATE 1,4:PRINT "Rezultat";s:COLOR 9:LOCATE 1,24:PRINT "Rekord"H COLOR 15:FOR i=4 TO 37:LOCATE 4,i:PRINT E$:LOCATE 21,41-i:PRINT E$ LOCATE 2+i/2,4:PRINT E$:LOCATE 23-i/2,37:PRINT E$:NEXT t$="(":FOR i=1 TO 5:t$=t$+t$:NEXT:COLOR 14,1:FOR i=6 TO 20:LOCATE i,5:PRINT t$:NEXT FOR i=1 TO 20:COLOR 4,0:LOCATE 6+INT(RND(2)*14.9),5+INT(RND(2)*31.9):PRINT "*":NEXT COLOR 12,1:FOR i=1 TO l 100 b=6+INT(RND(2)*14.9):a=5+INT(RND(2)*31.9) 110 IF POINT(a*6-2,b*8-2)<>14 OR (a=36 AND b=6) THEN 100 120 LOCATE b,a:PRINT ")":NEXT:COLOR 0,0 130 COLOR 10:LOCATE y,x:PRINT "&":COLOR 9:LOCATE my,mx:PRINT "'" 140 IF STICK(2) OR STICK(3) THEN 150 145 GOTO 140 150 GOSUB 260 160 COLOR 8:LOCATE 1,13:PRINT s 170 GOSUB 350 180 IF mx=x AND my=y THEN 220 190 IF n<l THEN 150 200 IF l<35 THEN l=l+1 210 GOTO 30 220 COLOR 5:LOCATE 23,4:PRINT "Kraj na igrata !" 230 IF s>H THEN H=s:COLOR 6:LOCATE 23,19:PRINT "S now rekord !" 240 LOCATE 25,4:PRINT "O}e edna igra ? <D/N>" 241 t$=INKEY$:IF t$="N" OR t$="n" THEN 250 242 IF t$=" " OR t$="D" OR t$="d" OR t$="Y" OR t$="y" THEN 20 ELSE 241 250 SYSTEM 260 a=x:b=y:o=STICK(2):p=STICK(3) IF o<0 AND x>5 THEN x=x+o:GOTO 310 IF o>0 AND x<36 THEN x=x+o:GOTO 310 IF p>0 AND y<20 THEN y=y+p:GOTO 310 IF p<0 AND y>5 THEN y=y+p 310 IF POINT(x*6-2,y*8-2)=12 THEN s=s+10:n=n+1 IF POINT(x*6-1,y*8-1)=4 THEN x=a:y=b IF (b<>y OR a<>x) AND POINT(x*6-2,y*8-2)=14 THEN s=s+1 LOCATE b,a:PRINT " ":COLOR 10:LOCATE y,x:PRINT "&":RETURN 350 a=mx:b=my:mx=mx+xd:my=my+yd IF mx=x AND my=y THEN PRINT " ":RETURN IF mx<5 OR mx>36 OR my>20 OR my<5 THEN mx=a:my=b:GOSUB 460:GOTO 420 IF POINT(mx*6-2,my*8-1)<>0 THEN mx=a:my=b:GOSUB 460:GOTO 420 390 IF xd<>0 THEN GOTO 430 400 IF mx<x THEN IF POINT(mx*6+4,my*8-1)=0 THEN xd=1:yd=0 IF mx>x THEN IF POINT(mx*6-8,my*8-1)=0 THEN xd=-1:yd=0 420 COLOR 0:LOCATE b,a:PRINT " ":COLOR 9:LOCATE my,mx:PRINT "'":RETURN 430 IF my<y THEN IF POINT(mx*6-1,my*8+7)=0 THEN yd=1:xd=0 440 IF my>y THEN IF POINT(mx*6-1,my*8-9)=0 THEN yd=-1:xd=0 450 GOTO 420 460 IF xd<>0 THEN GOTO 490 IF mx<31 THEN IF POINT(mx*6+4,my*8-1)=0 THEN xd=-1:yd=0:RETURN 480 xd=-xd:yd=-yd:RETURN 490 IF my<20 THEN IF POINT(mx*6-1,my*8+7)=0 THEN yd=1:xd=0:RETURN IF my>5 THEN IF POINT(mx*6-1,my*8-9)=0 THEN yd=-1:xd=0:RETURN GOTO 480 Title: CLS:COLOR 12:FOR i=1 TO 28 STEP 2 FOR j=3 TO 53 STEP 2:LOCATE i,j-b:PRINT CHR$(128):LOCATE i+1,j-b:PRINT CHR$(129):NEXT:b=NOT b:NEXT FOR i=1 TO 23:READ a:a$=a$+CHR$(a+160):b$=b$+CHR$(a+161):NEXT COLOR 9:LOCATE 13,18:PRINT a$:LOCATE 14,18:PRINT b$ Watt: i=i+1:IF i=5000 OR STICK(2) OR STICK(3) THEN RETURN ELSE Watt DATA 94,94,38,24,42,58,22,0,94,94,46,94,94,14,36,0,8,18,28,0,40,0,94 */